﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;

namespace SELF.Controls
{
    public partial class dialog_alert : DevExpress.XtraEditors.XtraForm
    {
        public dialog_alert()
        {
            InitializeComponent();
        }
        int remain = 10;
        Timer tm = new Timer();
        /// <summary>
        /// show this object at top right of screen,far 50 px from border
        /// </summary>
        private void dialog_alert_Load(object sender, EventArgs e)
        {
            this.Location = new Point(ClientSize.Width + 590, 50);
            //label2.Text = remain.ToString();
            tm.Interval = 1000;
            tm.Tick += new EventHandler(tm_Tick);
            tm.Start();
        }

        void tm_Tick(object sender, EventArgs e)
        {
            if (remain < 1)
            {
                tm.Stop();
                this.Close();
                this.Dispose();
            }
            else
            {
                remain -= 1;
                label2.Text = remain.ToString();
                Console.WriteLine(remain % 2);
                if ((remain % 2) == 1)
                {
                    tableLayoutPanel1.BackColor = Color.Blue;
                }
                else
                {
                    tableLayoutPanel1.BackColor = Color.Red;
                }
            }
            //throw new NotImplementedException();
        }
    }
}